package com.gdth.bank.presenter;

import org.greenrobot.eventbus.EventBus;

import com.gdth.bank.event.CjkhjlListEvent;
import com.gdth.bank.model.ChangePasswordModel;
import com.gdth.bank.view.ChangePasswordView;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class ChangePasswordPresenter {
	
	  private ChangePasswordModel  passwordbModel;
	  private ChangePasswordView   passwordView;
	  
	  public ChangePasswordPresenter(ChangePasswordView   passwordView) {
		  this.passwordView = passwordView;
		  passwordbModel = new ChangePasswordModel();
	  }
	   
	   //etc 数据保存到本地后上传
	 	public void changepassword(String str){
	 		passwordView.showProgressDialog("提交中");
	 		passwordbModel.changepassword(str)
	 			.subscribeOn(Schedulers.io())
	 			.unsubscribeOn(Schedulers.io())
	 			.observeOn(AndroidSchedulers.mainThread())
	 			.subscribe(new Subscriber<String>(){
	
	 				@Override
	 				public void onCompleted() {
	 					// TODO Auto-generated method stub
	 					passwordView.hideProgressDialog();
	 					
	 				}
	
	 				@Override
	 				public void onError(Throwable arg0) {
	 					// TODO Auto-generated method stub
	 					passwordView.hideProgressDialog();
	 					
	 				}
	
	 				@Override
	 				public void onNext(String arg0) {
	 					passwordView.hideProgressDialog();
	 					EventBus.getDefault().post(new CjkhjlListEvent(CjkhjlListEvent.CHANGE_PASSWORD,arg0));
	 					//passwordView.success();
	 				}
	 				
	 			});
	 	}

}
